<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-title" content="Amaze UI" />
<title>支付结果</title>
<link rel="stylesheet" href="../template/assets/css/amazeui.min.css"/>
<style type="text/css">
    .jump .am-btn-primary {
        color: #0e90d2;   
        background-color: #fff;    
        border-color: #0e90d2;
    }
    
/*   .jump .am-active .am-btn-primary.am-dropdown-toggle, .am-btn-primary.am-active, .am-btn-primary:active, .am-btn-primary:focus, .am-btn-primary:hover {   
        color: #0a6999;    
        border-color: #0a6999;
    }   */
    

    .jump .am-active .am-btn-primary.am-dropdown-toggle, .am-btn-primary.am-active, .jump:active, .jump:focus, .jump:hover {   
        color: #0a6999;    
        border-color: #0a6999;
    } 
    
    .jump:focus, .jump:hover {
        background-color: #fff;
                color: #0a6999;    
        border-color: #0a6999;
    }
    
/*     .a .am-btn-primary:focus, .am-btn-primary:hover {
        background-color: #fff;
        } */
    
  </style>
</head>
<body>
<div class="am-g am-padding-sm am-text-left">
 
 <div class = "am-u-sm-12 am-padding-vertical-sm">
     <div class = "am-u-sm-4">
                  支付状态：
    </div>
    <div class = "am-u-sm-8 am-text-primary am-text-sm" id="pay">
    </div>
 </div>
 
  <div class = "am-u-sm-12 am-padding-vertical-sm">
     <div class = "am-u-sm-4">
                  办理结果：
    </div>
    <div class = "am-u-sm-8 am-text-primary am-text-sm" id="order">
    </div>
 </div>
 
   <div class = "am-u-sm-12 am-padding-vertical-sm">
     <div class = "am-u-sm-4">
                  结果说明：
    </div>
    <div class = "am-u-sm-8 am-text-primary am-text-sm" id="msg">
    </div>
 </div>
 
  <div class = "am-u-sm-12 am-padding-vertical-sm am-text-xs am-text-danger">
   * 如收到银行扣款短信，订单状态还是未支付，请刷新或及时进入"消费记录"点击查询按钮（仅可查询当天订单）

  </div>
 
  <div class = "am-u-sm-12 am-padding-vertical-sm">
    <div class = "am-u-sm-5 am-padding-vertical-sm">
      <button type="button"  class="am-btn  am-btn-block am-btn-primary" id="refresh">刷新</button>
    </div>
    <div class = "jump am-u-sm-7 am-padding-vertical-sm">
      <button type="button"  class="am-btn  am-btn-block am-btn-primary" id="jump">查询历史缴费记录</button>
    </div>
  </div>
 
 </div>
 
<!--   <div class="am-text-center am-padding-top">   
    <p id="msg" name="msg" class="am-kai"></p>
  </div> -->
</body>
</html>
<script type="text/javascript" src="../template/assets/js/jquery.min.js"></script>
<!-- <script type="text/javascript" src="../template/assets/js/handlebars.min.js"></script>
<script type="text/javascript" src="../template/assets/js/amazeui.widgets.helper.min.js"></script> -->
<script type="text/javascript" src="../template/website/js/app.js"></script>
<script type="text/javascript">
//返回页面分享的参数,当当前页面有canAppS
$(document).ready(function(){    
    console.log("init");
    getStatus();
    $("#refresh").on("click", function() {
      $(this).prop('disabled', true);
      var orderId = getParamValue('orderId');
      var payStatus = $('#pay').html();
      if (/^C/i.test(orderId) && /未支付/g.test(payStatus)) {
    	  searchOrder();
      } else {
        window.location.reload();
      }
    });
    
    var userId=getParamValue("u");
    var token=getParamValue("t");
    
    $("#jump").on("click", function() {
       window.location.href='../dist/consumerecord.html?userId='+userId+'&token='+token;
      // window.location.href='http://dzgtest.vpclub.cn/dzg/dist/consumerecord.html?userId='+userId+'&token='+token;
    });
});

function getStatus(){
    var orderId=getParamValue("orderid");
    
    $.ajax({
           url : "../getOrderStatus",
           data : {"orderid":orderId},
           dataType : "json",
           async : true,
           success: function(data) {
               console.info(data);
               if(data.resultCode!=1000){
                   alert(data.message);
                   return;
               }
               $("#pay").html(data.data.pay); 
               $("#order").html(data.data.order); 
               $("#msg").html(data.data.msg); 
                   
               return;
           },
           error : function(textStatus) {
               //showTip("服务器请求失败，请联系管理员！");
               //sj2();
               console.info(textStatus);
               $("#msg").html("服务器出错"); 
           }
           
       });
}
function searchOrder() {
  var orderId = getParamValue('orderId');
  var token = getParamValue('t');
  var userId = getParamValue('u');
  var params = {
    'orderId': orderId,
    'userId': userId,
    'token': token
  };
  $.ajax({
    type: 'POST',
    url: '../ccb/searchOrder',
    data: params,
    dataType: 'json',
    success: function(data) {
      console.log(data.resultCode + ': ' + data.message);
      if (data.resultCode !== 1000) {
        alert(data.message);
      }
      window.location.reload();
    },
    error: function(textStatus) {
      console.info(textStatus);
      $("#msg").html("服务器出错"); 
    }
  });
}


</script>